<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateWaimaiOrderDetailTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('waimai_order_details', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('orderId')->default(0);
            $table->string('productName', 32)->default('')->comment('菜品名称');
            $table->string('unit', 8)->default('')->comment("菜品单位");
            $table->unsignedInteger('originalUnitPrice')->default(0)->comment("原单价");
            $table->unsignedInteger('num')->default(0)->comment("菜品数量");
            $table->unsignedInteger('payPrice')->default(0)->comment("应付总价");
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');

            $table->index('orderId', 'orderId_idx');
            $table->index('createdAt', 'createdAt_idx');
            $table->index('payPrice', 'payPrice_idx');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '外卖订单详情表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('waimai_order_details');
    }
}
